Skip to content

fix(quota-gatherer): install the OpenChamber lib checkout's declared dependencies before importing it (#8759) - #8764

Merged
dezren39 merged 2 commits into
mainfrom
queue/15013-8759-lib-deps
Nov 11, 2026
Merged

dezren39 merged 2 commits into
mainfrom
queue/15013-8759-lib-deps

Conversation

@dezren39

@dezren39 dezren39 commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

Fixes #8759 (queue task 15013).

Problem

Every quota-gatherer tick logged opendesign-renewal failed-soft: Cannot find package 'yaml' because the OpenChamber lib checkout named by OPENCHAMBER_LIB_DIR (~/git/openchamber-quota-lib, a plain clone) had no node_modules — its declared dependencies were never installed. The tick reported healthy while the OpenDesign renewal door was dead (since at least 2026-11-09).

Fix

  • New preflight pm-stack/aggregator/src/lib-deps.ts: before the gatherer's first lib import, walk the manifests from the lib dir to the checkout root (package.json + lockfile), check every declared package resolves from the lib dir, and if any are missing install the checkout's declared dependencies once at the root and re-check. Still-missing after install throws an explicit error naming the packages — dependency absence is a logged recovery or a loud failure, never a silent failed-soft.
  • Preflight rather than import-retry, by evidence: Bun caches a failed package resolution for the life of the process (verified on bun 1.4.4 — a retry import after installing still throws the cached ResolveMessage), so install-then-retry in one tick cannot work.
  • gather-quota.ts runs the preflight in runOpenDesignRenewal before importing the keeper's credential/provider modules. OPENCHAMBER_LIB_INSTALL_CMD overrides the install step (shell-split, like QUOTA_SUBCOMMAND); the default is bun install at the checkout root.

Tests (oracle: bun:test)

  • src/lib-deps.test.ts (7 tests): root discovery, missing/scoped package detection, clean-when-installed, install-exactly-once + re-check, no install when resolvable, explicit error naming still-missing packages, no-op outside a checkout.
  • test/gather-quota.test.ts e2e: a fixture checkout declaring an uninstalled package — the gatherer installs it (via the install-cmd seam), the keeper reaches a real outcome (status=not-configured for the fixture's null credential), and no failed-soft line is emitted.
  • Full targeted run: bun test src/lib-deps.test.ts src/opendesign-renewal.test.ts test/gather-quota.test.ts — 20/20 pass. bunx tsc --noEmit: no errors in touched files; total error lines identical to main (78, pre-existing elsewhere).

Live verification (acceptance)

  • bun install --frozen-lockfile in ~/git/openchamber-quota-lib: 1525 packages installed, checkout git status clean; both keeper modules now import cleanly.
  • Triggered a real tick (19:37Z): opendesign-renewal: status=valid horizonHours=150.8 capture=not-attempted, no Cannot find package 'yaml' in the journal, tick 16/16 providers ok.

Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

…dependencies before importing it (#8759)

The OpenDesign keeper imports from a plain-clone OpenChamber lib checkout; when the checkout was refreshed without an install step it had no node_modules, so every tick failed-soft with Cannot find package yaml while reporting healthy. A new lib-deps preflight (src/lib-deps.ts) checks every package declared in the manifests on the lib path resolves from the lib dir, installs the checkout's declared dependencies once at the root when any are missing, and re-checks — throwing an explicit error naming still-missing packages instead of a silent failed-soft. Preflight, not import-retry: Bun caches failed package resolution for the process (verified on bun 1.4.4). OPENCHAMBER_LIB_INSTALL_CMD overrides the install step (default bun install at the checkout root). Live remediation done with this fix: bun install --frozen-lockfile in ~/git/openchamber-quota-lib (1525 packages); the 19:37Z tick logged opendesign-renewal status=valid horizonHours=150.8 with no yaml error, 16/16 providers ok.
@dezren39
dezren39 requested a review from a team as a code owner November 11, 2026 19:39
@coderabbitai

coderabbitai Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 35 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 702a04ff-0149-4c64-9186-976938b7af98
Commits

Reviewing files that changed from the base of the PR and between 02af66b and 27818b5.

Files selected for processing: 4

  • pm-stack/aggregator/scripts/gather-quota.ts
  • pm-stack/aggregator/src/lib-deps.test.ts
  • pm-stack/aggregator/src/lib-deps.ts
  • pm-stack/aggregator/test/gather-quota.test.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-11T19:47:09.119392Z 27818b5 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c3786276d5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread pm-stack/aggregator/src/lib-deps.ts Outdated
import { basename, dirname, join } from "node:path";

const LOCKFILES = ["bun.lock", "bun.lockb", "package-lock.json", "pnpm-lock.yaml", "yarn.lock"];
const DEPENDENCY_FIELDS = ["dependencies", "devDependencies", "peerDependencies", "optionalDependencies"];

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Exclude optional packages from mandatory dependency checks

If the lib checkout declares an optional dependency that is intentionally absent, such as a platform-specific package, this makes that absence block the OpenDesign keeper even when its actual imports would succeed. ensureLibDependencies attempts an installation and then throws when the optional package remains absent; runOpenDesignRenewal catches that error before importing or running the keeper, repeating the same failure every tick. Preserve dependency optionality rather than treating every optionalDependencies entry as a required installation postcondition.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in the next commit: mandatory checks now cover only dependencies + devDependencies. optionalDependencies (e.g. packages/web's node-llama-cpp, platform-specific and intentionally absent on some installs) and peerDependencies (supplied by the consumer) are excluded from both the missing-check and the post-install postcondition, with the reason recorded in a comment at DEPENDENCY_FIELDS. Added a regression test: a checkout whose optional + peer packages are absent while its mandatory package resolves reports nothing missing and runs no install.

… postconditions (#8759)

Codex P2 on PR #8764: an optionalDependency that is intentionally absent (platform-specific, e.g. packages/web node-llama-cpp) would have blocked the OpenDesign keeper every tick. Mandatory checks now cover dependencies + devDependencies only, with a regression test.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

quota-gatherer: opendesign-renewal fails on every tick — "Cannot find package 'yaml'" in the OPENCHAMBER_LIB_DIR checkout (no node_modules)

1 participant